﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Happy.Examples.OrderManagement.Domain.Orders;

namespace Happy.Examples.OrderManagement.Domain.Test.Orders
{
    [TestClass]
    public class OrderInNewStateTest
    {
        [TestMethod]
        public void Order_In_NewState_Test()
        {
            var order = TestHelper.CreateOrderInNewState();

            Assert.AreEqual(OrderStatus.New, order.Status);
        }

        [TestMethod]
        public void Order_In_NewState_ChangeOrder_Test()
        {
            var order = TestHelper.CreateOrderInNewState();

            order.ChangeCustomerInfo(TestHelper.StubCustomerInfos["Jack"]);

            Assert.AreEqual("Jack", order.CustomerInfo.Name);
        }

        [TestMethod]
        public void Order_In_NewState_Save_Test()
        {
            var order = TestHelper.CreateOrderInNewState();

            order.Save();

            Assert.AreEqual(OrderStatus.Saved, order.Status);
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException))]
        public void Order_In_NewState_Submit_Test()
        {
            var order = TestHelper.CreateOrderInNewState();

            order.Submit();
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException))]
        public void Order_In_NewState_Audit_Test()
        {
            var order = TestHelper.CreateOrderInNewState();

            order.Audit();
        }
    }
}
